<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/file/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/file/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/file/favicon-16x16.png">
  <link rel="mask-icon" href="/file/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"czlz.net","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="前言万众瞩目的逆向来了。看看能不能学懂。">
<meta property="og:type" content="article">
<meta property="og:title" content="逆向第一天（大比武_CTF课_第十六天）">
<meta property="og:url" content="https://czlz.net/2020/jxsw_dbw_reverse_1/index.html">
<meta property="og:site_name" content="粗制乱造的个人网站">
<meta property="og:description" content="前言万众瞩目的逆向来了。看看能不能学懂。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/1.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/2_1.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/2_2.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/2_3.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/3_3.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/3_2.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/3_1.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/3_4.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/4_1.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/4_2.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/4_3.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/4_4.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/4_5.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/5_1.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/5_2.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/5_4.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/5_3.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/5_5.png">
<meta property="og:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/5_6.png">
<meta property="article:published_time" content="2020-07-19T16:00:00.000Z">
<meta property="article:modified_time" content="2020-07-24T12:29:04.574Z">
<meta property="article:author" content="粗制乱造">
<meta property="article:tag" content="CTF">
<meta property="article:tag" content="练习题">
<meta property="article:tag" content="reverse">
<meta property="article:tag" content="逆向">
<meta property="article:tag" content="汇编">
<meta property="article:tag" content="C语言">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://czlz.net/2020/jxsw_dbw_reverse_1/1.png">

<link rel="canonical" href="https://czlz.net/2020/jxsw_dbw_reverse_1/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>逆向第一天（大比武_CTF课_第十六天） | 粗制乱造的个人网站</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">粗制乱造的个人网站</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">杂七杂八的一堆东西</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-python">

    <a href="/pyodide/" rel="section"><i class="fa fa-user fa-fw"></i>在线Python3.8</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://czlz.net/2020/jxsw_dbw_reverse_1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/file/avatar.png">
      <meta itemprop="name" content="粗制乱造">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="粗制乱造的个人网站">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          逆向第一天（大比武_CTF课_第十六天）
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-07-20 00:00:00" itemprop="dateCreated datePublished" datetime="2020-07-20T00:00:00+08:00">2020-07-20</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-07-24 20:29:04" itemprop="dateModified" datetime="2020-07-24T20:29:04+08:00">2020-07-24</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/" itemprop="url" rel="index"><span itemprop="name">CTF</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">笔记</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/%E7%AC%94%E8%AE%B0/reverse/" itemprop="url" rel="index"><span itemprop="name">reverse</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/%E7%AC%94%E8%AE%B0/reverse/%E5%8E%9F%E7%90%86/" itemprop="url" rel="index"><span itemprop="name">原理</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><pre><code>万众瞩目的逆向来了。看看能不能学懂。</code></pre><a id="more"></a>
<hr>
<h1 id="解题"><a href="#解题" class="headerlink" title="解题"></a>解题</h1><h2 id="0x01-check-exe"><a href="#0x01-check-exe" class="headerlink" title="0x01 check.exe"></a>0x01 check.exe</h2><h3 id="分析"><a href="#分析" class="headerlink" title="分析"></a>分析</h3><p>这是一个I386的程序。<br>丢进IDA。直接就定位到了Main方法。这题比较简单，进入sub_401050。<br>直接就看到了flag.</p>
<h3 id="flag"><a href="#flag" class="headerlink" title="flag"></a>flag</h3><p><img src="1.png" alt=""><br>flag{sAdf_fDfkl_Fdf}</p>
<h2 id="0x02-cm-exe"><a href="#0x02-cm-exe" class="headerlink" title="0x02 cm.exe"></a>0x02 cm.exe</h2><h3 id="分析-1"><a href="#分析-1" class="headerlink" title="分析"></a>分析</h3><p>用了一个密码表+一个asic转换的方式。<br><img src="2_1.png" alt=""><br><img src="2_2.png" alt=""></p>
<h3 id="用代码还原"><a href="#用代码还原" class="headerlink" title="用代码还原"></a>用代码还原</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#密码表</span></span><br><span class="line">pwd = <span class="string">"abcdefghiABCDEFGHIJKLMNjklmn0123456789opqrstuvwxyzOPQRSTUVWXYZ"</span></span><br><span class="line"><span class="comment">#明文</span></span><br><span class="line">flag=<span class="string">"KanXueCTF2019JustForhappy"</span></span><br><span class="line"></span><br><span class="line">tmp=[]</span><br><span class="line"><span class="comment">#获取明文在密码表中的位置</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> flag:</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> pwd:</span><br><span class="line">        <span class="keyword">if</span> i==j:</span><br><span class="line">            tmp.append(pwd.index(j))</span><br><span class="line"></span><br><span class="line">print(tmp)</span><br><span class="line">f=<span class="string">""</span></span><br><span class="line"><span class="comment">#还原密码</span></span><br><span class="line"><span class="keyword">for</span> t <span class="keyword">in</span> tmp:</span><br><span class="line">    <span class="keyword">if</span>(t+<span class="number">29</span>&gt;<span class="number">64</span> <span class="keyword">and</span> t+<span class="number">29</span>&lt;<span class="number">91</span>):</span><br><span class="line">        f=f+chr(t+<span class="number">29</span>)</span><br><span class="line">    <span class="keyword">if</span>(t+<span class="number">87</span>&gt;<span class="number">96</span> <span class="keyword">and</span> t+<span class="number">87</span>&lt;<span class="number">123</span>):</span><br><span class="line">        f=f+chr(t+<span class="number">87</span>)</span><br><span class="line">    <span class="keyword">if</span>(t+<span class="number">48</span>&gt;<span class="number">47</span> <span class="keyword">and</span> t+<span class="number">48</span>&lt;<span class="number">58</span>):</span><br><span class="line">        f=f+chr(t+<span class="number">48</span>)</span><br><span class="line"></span><br><span class="line">print(f)</span><br></pre></td></tr></table></figure>

<h3 id="flag-1"><a href="#flag-1" class="headerlink" title="flag"></a>flag</h3><p><img src="2_3.png" alt=""><br>j0rXI4bTeustBiIGHeCF70DDM</p>
<h2 id="0x03-Crackme150-exe"><a href="#0x03-Crackme150-exe" class="headerlink" title="0x03 Crackme150.exe"></a>0x03 Crackme150.exe</h2><h3 id="分析-2"><a href="#分析-2" class="headerlink" title="分析"></a>分析</h3><p><img src="3_3.png" alt=""><br>用IDA加载，直接定位到这里。<br>第一个判断是Vxv2erVassxdYcv2bg9nbttyZetSxd1zx0sxbawyac1avX12c78HvfNbnlioYtrwW。<br>这应当是flag加密后的代码。<br>有用的是用户名：Wpsec<br><img src="3_2.png" alt=""><br>跟进到sub_401140函数。这一堆估计都是解密的程序，不管直接跳到关键跳。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> ( <span class="built_in">strcmp</span>(v19, a1) )</span><br><span class="line">   <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line"> dword_4033BC = (<span class="keyword">int</span>)sub_401000(<span class="built_in">strlen</span>(&amp;v22), (<span class="keyword">int</span>)&amp;v22);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">1</span>;</span><br></pre></td></tr></table></figure>
<p>这里比较成功就返回1失败就返回假，所以这里一定是关键跳。<br><img src="3_1.png" alt=""></p>
<h3 id="解题-1"><a href="#解题-1" class="headerlink" title="解题"></a>解题</h3><p>转到汇编模式找到地址，开始动态调试。<br>用户名输入Wpsec，密码乱输几个字符。然后跟进到00401310地址<br><img src="3_4.png" alt=""><br>一下就出来了。</p>
<h3 id="flag-2"><a href="#flag-2" class="headerlink" title="flag"></a>flag</h3><p>flag:{Welcome-to-Wpsec}</p>
<h2 id="0x04-game-exe"><a href="#0x04-game-exe" class="headerlink" title="0x04 game.exe"></a>0x04 game.exe</h2><h3 id="分析-3"><a href="#分析-3" class="headerlink" title="分析"></a>分析</h3><p>拿到题题直接上IDA，然后按F5，看到这里比较特别<br><img src="4_1.png" alt=""><br>这么多判断吗？跟进sub_457AB4函数看一下。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">int sub_457AB4(void)</span><br><span class="line">&#123;</span><br><span class="line">  return sub_45E940();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>再跟进sub_45E940看一下。<br><img src="4_2.png" alt=""><br>看到了done!!! the flag is 。看来这把会比较快GG了。</p>
<h3 id="解题-2"><a href="#解题-2" class="headerlink" title="解题"></a>解题</h3><p>拿出动态调试工具，通过IDA分析出的地址直接跟过去。<br><img src="4_3.png" alt=""><br>找到关键call 0x00457AB4并记下。然后在关键判断前插入这个call<br><img src="4_4.png" alt=""></p>
<h2 id="flag-3"><a href="#flag-3" class="headerlink" title="flag"></a>flag</h2><p>运行后<br><img src="4_5.png" alt=""><br>flag就出现了<br>zsctf{T9is_tOpic_1s_v5ry_int7resting_b6t_others_are_n0t}</p>
<h2 id="0x05-DbgIsFun-exe"><a href="#0x05-DbgIsFun-exe" class="headerlink" title="0x05. DbgIsFun.exe"></a>0x05. DbgIsFun.exe</h2><h3 id="分析-4"><a href="#分析-4" class="headerlink" title="分析"></a>分析</h3><p>用IDA载入程序。一堆的SUB，看看有没有啥能看懂的东西，发现几个特别的函数。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">TlsCallback</span><br><span class="line">TopLevelExceptionFilter</span><br><span class="line">_SEH_prolog4</span><br><span class="line">_SEH_epilog4 </span><br><span class="line">SEH_4125A0</span><br></pre></td></tr></table></figure>
<p>搜索了一下发现TlsCallback很多时候用于反调试。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> __stdcall <span class="title">TlsCallback_0</span><span class="params">(<span class="keyword">int</span> a1, <span class="keyword">int</span> a2, <span class="keyword">int</span> a3)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">signed</span> <span class="keyword">int</span> v3; <span class="comment">// eax</span></span><br><span class="line">  DWORD flOldProtect; <span class="comment">// [esp+0h] [ebp-8h]</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> ( a2 == <span class="number">1</span> )</span><br><span class="line">  &#123;</span><br><span class="line">    VirtualProtect(StartAddress, <span class="number">0x42E</span>u, <span class="number">0x40</span>u, &amp;flOldProtect);</span><br><span class="line">    v3 = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">do</span></span><br><span class="line">    &#123;</span><br><span class="line">      *((_BYTE *)StartAddress + v3) ^= v3;</span><br><span class="line">      ++v3;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">while</span> ( v3 &lt; <span class="number">1070</span> );</span><br><span class="line">    CreateThread(<span class="number">0</span>, <span class="number">0</span>, (LPTHREAD_START_ROUTINE)StartAddress, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>);</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在VirtualProtect：00401026在下断点，跟一下解密。<br>flOldProtect所以地址应当就是解密后的地址了。<br><img src="5_1.png" alt="5_1.png"><br>2、另外需要在Main函数中下一个断点，我们先恢复一下main<br><img src="5_2.png" alt="5_1.png"><br>先将这些花指定回复，再重新create function。恢复main函数,F5这样就可以显示出源码了。<br><img src="5_4.png" alt="5_1.png"><br>接下去OD里面进行动态调试。<br><img src="5_3.png" alt="5_1.png"><br>跳到解密后的程序中去。<br><img src="5_5.png" alt="5_1.png"><br>跟了一下，拿到一串密码。<br>0x47,0x48,0x43,0x54,0x46<br><img src="5_6.png" alt="5_2.png"><br>向下跟了一下，发现了密文。开始拿RC4解密。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> Crypto.Cipher <span class="keyword">import</span> ARC4</span><br><span class="line"></span><br><span class="line">key=[<span class="number">0x47</span>,<span class="number">0x4B</span>,<span class="number">0x43</span>,<span class="number">0x54</span>,<span class="number">0x46</span>]</span><br><span class="line">pwd=<span class="string">"2D,D4,0F,D0,54,EE,75,D0,E0,30,96,E1,79,8A,E0,FE,18,3A,27,E7,2F,86,C9,FE,66,43,A7,75"</span>.split(<span class="string">","</span>)</span><br><span class="line">newpwd=<span class="string">b""</span></span><br><span class="line">newkey=<span class="string">""</span></span><br><span class="line"><span class="keyword">for</span> v <span class="keyword">in</span> key:</span><br><span class="line">    newkey+=chr(v)</span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> v <span class="keyword">in</span> pwd:</span><br><span class="line">    newpwd+=int(v,<span class="number">16</span>).to_bytes(<span class="number">1</span>,<span class="string">'little'</span>)</span><br><span class="line"></span><br><span class="line">print(newkey)</span><br><span class="line">rc4=ARC4.new(newkey.encode(<span class="string">'utf-8'</span>))</span><br><span class="line">flag = rc4.decrypt(newpwd)</span><br><span class="line">newflag=<span class="string">""</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> range(<span class="number">256</span>):</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> flag:</span><br><span class="line">        newflag+=chr(i^j)</span><br><span class="line">    <span class="keyword">if</span>(newflag.find(<span class="string">"flag"</span>)!=<span class="number">-1</span>):</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    newflag=<span class="string">""</span></span><br><span class="line">    </span><br><span class="line">print(newflag)</span><br></pre></td></tr></table></figure>
<h3 id="flag-4"><a href="#flag-4" class="headerlink" title="flag"></a>flag</h3><p>flag{5tay4wayFr0m8reakp0int}</p>
<h2 id="0x06-picoCTF-main"><a href="#0x06-picoCTF-main" class="headerlink" title="0x06. picoCTF_main"></a>0x06. picoCTF_main</h2><h3 id="分析-5"><a href="#分析-5" class="headerlink" title="分析"></a>分析</h3><p>这题是算法题了。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">do_magic</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">int</span> result; <span class="comment">// eax</span></span><br><span class="line">  <span class="keyword">int</span> v1; <span class="comment">// [esp+Ch] [ebp-1Ch]</span></span><br><span class="line">  <span class="keyword">int</span> i; <span class="comment">// [esp+10h] [ebp-18h]</span></span><br><span class="line">  <span class="keyword">char</span> *s; <span class="comment">// [esp+14h] [ebp-14h]</span></span><br><span class="line">  <span class="keyword">signed</span> <span class="keyword">int</span> v4; <span class="comment">// [esp+18h] [ebp-10h]</span></span><br><span class="line">  <span class="keyword">void</span> *v5; <span class="comment">// [esp+1Ch] [ebp-Ch]</span></span><br><span class="line"></span><br><span class="line">  s = read_input();</span><br><span class="line">  v4 = <span class="built_in">strlen</span>(s);</span><br><span class="line">  v5 = <span class="built_in">malloc</span>(v4 + <span class="number">1</span>);</span><br><span class="line">  <span class="keyword">if</span> ( !v5 )</span><br><span class="line">  &#123;</span><br><span class="line">    <span class="built_in">puts</span>(<span class="string">"malloc() returned NULL. Out of Memory\n"</span>);</span><br><span class="line">    <span class="built_in">exit</span>(<span class="number">-1</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="built_in">memset</span>(v5, <span class="number">0</span>, v4 + <span class="number">1</span>);</span><br><span class="line">  v1 = <span class="number">0</span>;</span><br><span class="line">  <span class="keyword">for</span> ( i = <span class="number">0</span>; ; ++i )</span><br><span class="line">  &#123;</span><br><span class="line">    result = i;</span><br><span class="line">    <span class="keyword">if</span> ( i &gt;= v4 )</span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">if</span> ( greetingMessage[i] == (*(i + <span class="number">0x8048858</span>) ^ s[i]) )</span><br><span class="line">      ++v1;</span><br><span class="line">    <span class="keyword">if</span> ( v1 == <span class="number">25</span> )</span><br><span class="line">      <span class="keyword">return</span> <span class="built_in">puts</span>(<span class="string">"You are winner!"</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">return</span> result;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>核心算法比较简单<br>直接写个脚本</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">id = <span class="string">"You have now entered the Duck Web, and you're in for a honk"</span></span><br><span class="line">key=[<span class="number">0x29</span>,<span class="number">0x6</span>,<span class="number">0x16</span>,<span class="number">0x4F</span>,<span class="number">0x2B</span>,<span class="number">0x35</span>,<span class="number">0x30</span>,<span class="number">0x1E</span>,<span class="number">0x51</span>,<span class="number">0x1B</span>,<span class="number">0x5B</span>,<span class="number">0x14</span>,<span class="number">0x4B</span>,<span class="number">0x8</span>,<span class="number">0x5D</span>,<span class="number">0x2B</span>,<span class="number">0x50</span>,<span class="number">0x14</span>,<span class="number">0x5D</span>,<span class="number">0x0</span>,<span class="number">0x19</span>,<span class="number">0x17</span>,<span class="number">0x59</span>,<span class="number">0x52</span>,<span class="number">0x5D</span>,<span class="number">0x0</span>]</span><br><span class="line"></span><br><span class="line">flag=<span class="string">""</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> range(<span class="number">0</span>,<span class="number">25</span>):</span><br><span class="line">    flag+=chr(ord(id[i])^key[i])</span><br><span class="line">print(flag)</span><br></pre></td></tr></table></figure>
<h3 id="flag-5"><a href="#flag-5" class="headerlink" title="flag"></a>flag</h3><p>picoCTF{qu4ckm3_5f8d9c17}</p>

    </div>

    
    
    
        <div class="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/file/weixin.png" alt="粗制乱造 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/file/zfb.png" alt="粗制乱造 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/CTF/" rel="tag"># CTF</a>
              <a href="/tags/%E7%BB%83%E4%B9%A0%E9%A2%98/" rel="tag"># 练习题</a>
              <a href="/tags/reverse/" rel="tag"># reverse</a>
              <a href="/tags/%E9%80%86%E5%90%91/" rel="tag"># 逆向</a>
              <a href="/tags/%E6%B1%87%E7%BC%96/" rel="tag"># 汇编</a>
              <a href="/tags/C%E8%AF%AD%E8%A8%80/" rel="tag"># C语言</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/jxsw_dbw_crypto_RSA/" rel="prev" title="密码学RSA题总结">
      <i class="fa fa-chevron-left"></i> 密码学RSA题总结
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/jxsw_dbw_reverse_2/" rel="next" title="逆向第二天（大比武_CTF课_第十八天）">
      逆向第二天（大比武_CTF课_第十八天） <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#解题"><span class="nav-number">2.</span> <span class="nav-text">解题</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#0x01-check-exe"><span class="nav-number">2.1.</span> <span class="nav-text">0x01 check.exe</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#分析"><span class="nav-number">2.1.1.</span> <span class="nav-text">分析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flag"><span class="nav-number">2.1.2.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x02-cm-exe"><span class="nav-number">2.2.</span> <span class="nav-text">0x02 cm.exe</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#分析-1"><span class="nav-number">2.2.1.</span> <span class="nav-text">分析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#用代码还原"><span class="nav-number">2.2.2.</span> <span class="nav-text">用代码还原</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flag-1"><span class="nav-number">2.2.3.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x03-Crackme150-exe"><span class="nav-number">2.3.</span> <span class="nav-text">0x03 Crackme150.exe</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#分析-2"><span class="nav-number">2.3.1.</span> <span class="nav-text">分析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解题-1"><span class="nav-number">2.3.2.</span> <span class="nav-text">解题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flag-2"><span class="nav-number">2.3.3.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x04-game-exe"><span class="nav-number">2.4.</span> <span class="nav-text">0x04 game.exe</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#分析-3"><span class="nav-number">2.4.1.</span> <span class="nav-text">分析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解题-2"><span class="nav-number">2.4.2.</span> <span class="nav-text">解题</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#flag-3"><span class="nav-number">2.5.</span> <span class="nav-text">flag</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x05-DbgIsFun-exe"><span class="nav-number">2.6.</span> <span class="nav-text">0x05. DbgIsFun.exe</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#分析-4"><span class="nav-number">2.6.1.</span> <span class="nav-text">分析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flag-4"><span class="nav-number">2.6.2.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x06-picoCTF-main"><span class="nav-number">2.7.</span> <span class="nav-text">0x06. picoCTF_main</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#分析-5"><span class="nav-number">2.7.1.</span> <span class="nav-text">分析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flag-5"><span class="nav-number">2.7.2.</span> <span class="nav-text">flag</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="粗制乱造"
      src="/file/avatar.png">
  <p class="site-author-name" itemprop="name">粗制乱造</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">43</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">59</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">粗制乱造</span>
</div>
  <div class="powered-by">由 <a href="https://czlz.net/" class="theme-link">czlz.net</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
